package com.changli06.otherStream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Logger {
    public static void log(String msg) {
        try {
            PrintStream out = new PrintStream(new FileOutputStream("log.txt",true));
            System.setOut(out);
            Date date  = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
            String time = sdf.format(date);
            System.out.println(time +"->" + msg);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }


    }
}
